exports.getSignPackage = function(req,res) {

    //获取restful参数
    var bdoyParams = req.routeInfo.bodyParams;

    //最终反回结果
    var resultData = {};

    //保存access_token
    var accessToken = "";

    //保存jsapi_ticket
    var jsapiTicket = "";

    //任务流创建
    async.waterfall([

        //获取accessToken
        (cb) =>{
            R.SEND_HTTP(
                req,
                {
                    url    : "http://"+config.publicConfig.SERVER_IP+":8800/weixin/getAccessToken",
                    method : 'GET'
                },
                function (err, data) {

                    if(err){
                        return RES.errorResponse(res,"公众号config配置签名获取失败");
                    }

                    access_token = data.result;
                    //console.log("access_token:" + access_token);
                    
                    cb();
            
                }
            );

        },

        //获取jsapi_ticket
        (cb) =>{
            
            R.SEND_HTTP(
                req,
                {
                    url    : "http://"+config.publicConfig.SERVER_IP+":8800/weixin/getJsapiTicket/access_token/" + access_token,
                 // url    : "http://127.0.0.1:8800/weixin/getJsapiTicket/access_token/" + access_token,
                    method : 'GET'
                },
                function (err, data) {

                    if(err){
                        return RES.errorResponse(res,"公众号config配置签名获取失败");
                    }

                    jsapiTicket = data.jsapi_ticket;
                    //console.log("jsapiTicket:" + jsapiTicket);
                    
                    cb();
            
                }
            );

        },

        //获取签名
        (cb) =>{

            var nowTime   = common.nowTime(false);

            var randStr   = common.getRandom(5);

            var urlStr    = "jsapi_ticket="+jsapiTicket+"&noncestr="+randStr+"&timestamp="+nowTime+"&url="+bdoyParams.url;


            var jsSHA     = require('jssha');

            var shaObj    = new jsSHA(urlStr, 'TEXT');

            var signature = shaObj.getHash('SHA-1', 'HEX');

            resultData.timestamp = nowTime;
            resultData.nonceStr  = randStr;
            resultData.signature = signature;
            // resultData.appId     = "wx93afa21da0f31762";//正式服
//          resultData.appId     = "wx9d7965ae361cc36b";//艺修歌
            resultData.appId     = "wxc6f6ebfcc26c687c";//校营通
//          resultData.appId     = "wx241a44107bf6b525";//乐器乌托邦

            cb();
        }

    ], () =>{

        //返回最终拼接结果
		RES.successResponse(res, resultData);
    
    });

}